package com.jt.controller;

import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller //跳转页面
public class UserController {
    @Autowired
    private UserMapper userMapper;
@RequestMapping("/findAll")
    public String findAll(Model model){
    List<User> userList = userMapper.selectList(null);
    model.addAttribute("userList", userList);
    return "userList" ;
    }
    @RequestMapping("/ajax")
    public  String ajax(){
    return "userAjax";
    }
    @RequestMapping("/userAjax")
    @ResponseBody
    public List<User>userAjax(){
    return userMapper.selectList(null);
    }
}
